package com.csk.zsk.compents.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.csk.zsk.compents.dao.MusicDao;
import com.csk.zsk.compents.entity.Music;
import com.csk.zsk.compents.service.MusicService;

@Service
@Transactional
public class MusicServiceImpl implements MusicService {

	@Autowired
	private MusicDao musicDao;

	@Override
	public void saveMusic(Music music) {
		musicDao.save(music);
	}

	@Override
	public void deleteMusic(String id) {
		musicDao.delete(id);
	}

	@Override
	@Transactional(readOnly = true)
	public Music getMusic(String id) {
		return musicDao.get(id);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Music> getAll() {
		return musicDao.getAll();
	}

	@Override
	public void batchSaveMusic(List<Music> musicList) {
		for (int i = 0; i < musicList.size(); i++) {
			Music music = musicList.get(i);
			musicDao.save(music);
		}

	}

	@Override
	@Transactional(readOnly = true)
	public Music getMusicById(String id) {
		return musicDao.getIdByGetMethod(id);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Music> getNewMusic(Integer num) {
		return musicDao.getNewMusic(num);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Music> searchMusicByLike(String musicLike) {
		return musicDao.searchMusicByLike(musicLike);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Music> getMusicListByIds(List<String> idList) {
		return musicDao.getMusicListByIds(idList);
	}

}
